<?php

namespace Biz\model\bizAd;

use Biz\pockets\modelTrait\BizModelTrait;
use Doraemon\pockets\datebase\BaseDbModel;

class AdPlanDataFlow extends BaseDbModel
{
    const _CONFIG_FILE_ = 'db_biz_ad';

    const _CONFIG_SELECT_ = 'db_biz_ad';

    const _DATABASE_ = 'biz_ad';

    const _TABLE_NAME = 'hhz_ad_plan_data_flow';

    const TYPE_CREATE = 1;//新建
    const TYPE_APPEND = 2;//追加

    use BizModelTrait;

    public static function getInfoByWhere($where)
    {
        return self::dataSelectInfo($where);
    }

    public static function getListByWhere($where, array $field = [])
    {
        return self::dataSelect($where, $field);
    }

    public static function getFlowPackageIdsByWhere($where)
    {
        return self::dataPluck($where, 'flow_package_id');
    }

    public static function getPlanDataList($planId)
    {
        return self::dataSelect(['plan_id' => $planId]);
    }

    public static function getPlanFlowIds($planId)
    {
        $flowIds = self::dataSelect(['plan_id' => $planId], 'flow_package_id');
        return !empty($flowIds) ? $flowIds : [];
    }

    public static function addData($data)
    {
        $data['create_time'] = date('Y-m-d H:i:s');
        $id = self::dataInsert($data);
        return $id;
    }

    public static function updateData($planId, $data)
    {
        $data['update_time'] = date('Y-m-d H:i:s');
        return self::dataUpdate($data, ['id' => $planId]);
    }

}